<body class="laytp-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="" style="padding: 20px;">
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:130px">应用ID：</label>
        <div class="layui-input-inline" style="width:300px">
            <input type="text" name="config[app_id]" value="{$config.app_id|default=''}" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">腾讯广告应用ID</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="width:130px">应用密钥：</label>
        <div class="layui-input-inline" style="width:300px">
            <input type="text" name="config[app_secret]" value="{$config.app_secret|default=''}" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">腾讯广告应用密钥</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="width:130px">账户ID：</label>
        <div class="layui-input-inline" style="width:300px">
            <input type="text" name="config[account_id]" value="{$config.account_id|default=''}" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">腾讯广告账户ID</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="width:130px">API接口域名：</label>
        <div class="layui-input-inline" style="width:300px">
            <input type="text" name="config[api_url]" value="{$config.api_url|default='https://api.e.qq.com/v1.3/'}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="width:130px">沙箱环境：</label>
        <div class="layui-input-inline" style="width:300px">
            <input type="radio" name="config[is_sandbox]" value="1" title="开启" {if condition="$config.is_sandbox eq 1"}checked{/if}>
            <input type="radio" name="config[is_sandbox]" value="0" title="关闭" {if condition="$config.is_sandbox eq 0"}checked{/if}>
        </div>
        <div class="layui-form-mid layui-word-aux">是否启用沙箱环境</div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveConfig">保存配置</button>
        </div>
    </div>
</form>
    </div>
</div>
<script>
layui.use(['form'], function(){
    var form = layui.form;
    
    //监听提交
    form.on('submit(saveConfig)', function(data){
        $.ajax({
            url: '{:url("save")}',
            type: 'POST',
            data: data.field,
            success: function(res){
                if(res.code == 1){
                    layer.msg(res.msg, {icon: 1});
                }else{
                    layer.msg(res.msg, {icon: 2});
                }
            }
        });
        return false;
    });
});
</script>